package com.nineclock.auth.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

@Configuration
public class TokenConfig {
    //JWT令牌生成时的签名秘钥 ;
    @Value("nineclock.auth.signKey")
    private String SING_KEY;

    @Bean
    public TokenStore tokenStore(){
//        return new InMemoryTokenStore(); //在内存中存储令牌
        return new JwtTokenStore( tokenConverter());
    }

    @Bean
    public JwtAccessTokenConverter tokenConverter(){
        JwtAccessTokenConverter jwtAccessTokenConverter = new JwtAccessTokenConverter();
        jwtAccessTokenConverter.setSigningKey(SING_KEY); //签名密钥
        return jwtAccessTokenConverter;
    }


}